package com.rw.car.controller;

import com.rw.car.service.ConfigInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("info")
public class ConfigInfoController {


    @Autowired
    private ConfigInfoService configInfoService;


    @GetMapping("{key}")
    public Map<String, Object> getValueByKey(@PathVariable("key") String key){
        Map<String, Object> map =new HashMap<>();
        map.put("code",200);
        String value = configInfoService.getValueByKey(key.trim());
        if (value!=null){
            map.put("data",value);
        }else {
            map.put("code",199);
            map.put("msg","key不存在");
        }
        return map;
    }
}
